package com.rmb.engine.controller;


import com.rmb.engine.entity.Dictionary;
import com.rmb.engine.service.DictionaryService;
import com.rmb.annotation.SystemLog;
import com.rmb.enums.LogType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author ZhaoMuYang
 * @Date 2021/1/6 19:46
 */
@RestController
@RequestMapping("/rmb/dictionary")
public class DictionaryController {
    @Autowired
    private DictionaryService dictionaryService;

    /**
     * 查询数据源列表
     *
     * @return findList
     */
    @GetMapping("/findlist")
    @SystemLog(description = "查询数据源列表",type = LogType.SELETE)
    public List<Dictionary> findList() {
        return dictionaryService.findList();
    }

    @PostMapping("/addDictionary")
    @SystemLog(description = "添加",type = LogType.INSERT)
    public Dictionary addDictionary(@RequestBody Dictionary dictionary){
        return dictionaryService.addDictionary(dictionary);
    }

    @PutMapping("/PutDictionary")
    @SystemLog(description = "修改",type = LogType.UPDATE)
    public Dictionary putDictionary(@RequestBody Dictionary dictionary){
        return dictionaryService.update(dictionary);
    }

    @PutMapping("/del/{id}")
    @SystemLog(description = "删除",type = LogType.DELETE)
    public void del(@PathVariable Long id){
        dictionaryService.del(id);
    }
}
